// db_mysql.h: interface for the db_mysql class.
//
//////////////////////////////////////////////////////////////////////

#if !defined(AFX_DB_MYSQL_H__1B0149CA_F2A8_46EA_8ACE_67136F37329C__INCLUDED_)
#define AFX_DB_MYSQL_H__1B0149CA_F2A8_46EA_8ACE_67136F37329C__INCLUDED_

#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
#ifdef WIN32
#include <winsock2.h>
#endif
#include "mysql.h"

class db_mysql
{
public:
	int getnextuser(char *username,char *password,char *realname,char *idcardno,char *phoneno,char *address,int &type,char *opendate);
	int getupperuser(char *username,char *password,char *realname,char *idcardno,char *phoneno,char *address,int &type,char *opendate);
	unsigned long rows();
	void print_rows();
	int exec_sql(const char *sql);
	int open_db(const char *db);
	int connect(const char *host,const char *user,const char *passwd,const char *db,unsigned int port = MYSQL_PORT,const char *unix_socket = NULL,unsigned int client_flag = 0);
	int init();
	unsigned long getinsertid(){return mysql_insert_id(&m_MySQL);};
	const char *getlasterror(){return m_sLastError;};
	db_mysql();
	virtual ~db_mysql();
private:
	MYSQL  m_MySQL;
	MYSQL_RES *m_pMySQL_RES;
	char   m_sHost[128];
	char   m_sUserName[32];
	char   m_sPassword[32];
	char   m_sDBName[128];
	int    m_nPort;
	char   m_sUnix_Socket[128];
	
	unsigned int m_nClient_Flag;
	bool   m_bInited;
	bool   m_bConnected;
	unsigned long m_nRows_Readed;
public:
	void seek(unsigned long pos);
	MYSQL_ROW next();
	void close();
	int selectdb(const char *pdb);
	char   m_sLastError[1024];
};

//MYSQL *mysql_real_connect(MYSQL *mysql, const char *host, const char *user, const char *passwd, const char *db, unsigned int port, const char *unix_socket, unsigned int client_flag) 


#endif // !defined(AFX_DB_MYSQL_H__1B0149CA_F2A8_46EA_8ACE_67136F37329C__INCLUDED_)
